package com.djq.project.mq.producer.common;


import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 一般模式 消息队列
 * RecvCommon 接收
 */
@RestController
public class SendCommon {
    @Autowired
    private RabbitTemplate template;
    @RequestMapping("/sendCommon")
    @Scheduled(fixedDelay = 1000, initialDelay = 500)
    public void sendCommon() {
        String message = "Hello World!";
        // queues名称 ,消息
        this.template.convertAndSend("common", message);
        System.out.println(" [x] Sent '" + message + "'");
    }
}
